<template>
	<view>
		<view class="content">
			<view style="margin-top: 450rpx;" v-if="coupon_list.length<1">
				<u-empty mode="data" :iconSize='150' :textSize='24' text='暂无内容' icon=""></u-empty>
			</view>
			<view class="content_box" v-for="(item,index) in coupon_list" :key="item">
				<view style="padding: 20rpx;">
					<view class="content_box_1">
						<view class="content_box_1_left">
							<view>
								{{item.used_amount}}<text style="font-size: 24rpx;">元</text>
							</view>
							<view>
								满{{item.with_amount}}元可用
							</view>
						</view>
						<view class="content_box_1_right">
							<view>
								{{item.title}}
							</view>
							<view>
								{{item.draw_range}}
							</view>
						</view>
					</view>
					<view class="content_box_2">
						<view class="content_box_2_left" @tap="rule(index)">
							<view>使用规则</view>
							<view class="">
								<image src="https://can.clkejj.com/static/Project_drawing 18.png" mode=""></image>
							</view>
						</view>
						<view class="content_box_2_right" @tap="gonavget">
							去使用
						</view>
					</view>
					<view class="rule" v-show="item.show">
						{{item.remarks}}
					</view>
				</view>
			</view>
			<height :hg="20"></height>
		</view>
	</view>
</template>

<script>
	import {
		coupon_list
	} from "@/api/comm.js"
	export default {
		data() {
			return {
				coupon_list: [],
			};
		},
		onLoad() {
			this.coupon_listApi()
			if (!uni.getStorageSync('userinfo')) {
				this.enter = true
				uni.showToast({
					title: '未登录',
					icon: 'none'
				})
				return
			}
		},
		onShow() {
			if (!uni.getStorageSync('userinfo')) {
				this.enter = true
				uni.showToast({
					title: '未登录',
					icon: 'none'
				})
				return
			} else {
				this.enter = false
			}
		},
		methods: {
			rule(index) {
				if (this.coupon_list[index].show) {
					this.coupon_list[index].show = 0
				} else {
					this.coupon_list[index].show = 1
				}
			},
			async coupon_listApi() {
				let data = await coupon_list()
				if (data.code == 1) {
					this.coupon_list = []
					this.coupon_list.push(...data.data)
				} else {
					uni.showToast({
						title: data.msg,
						icon: "error"
					})
				}
			},
			gonavget() {
				uni.switchTab({
					url: '/pages/order/order'
				})
			},

		},

	}
</script>

<style lang="scss" scoped>
	.content_box {
		width: 702rpx;
		height: 230rpx;
		background: #FFFFFF;
		margin: 20rpx auto;
		border-radius: 20rpx;

		.content_box_1 {
			display: flex;
			align-items: center;

			.content_box_1_left {
				text-align: center;
				padding-left: 20rpx;
				padding-top: 20rpx;

				view:nth-child(1) {
					font-size: 40rpx;
					font-weight: 600;
					color: #FC3B4C;
				}

				view:nth-child(2) {
					font-size: 24rpx;
					font-weight: 400;
					color: #979797;
				}
			}

			.content_box_1_right {
				padding-left: 40rpx;
				padding-top: 30rpx;

				view:nth-child(1) {
					font-size: 32rpx;
					font-weight: 600;
					color: #3A3A3A;
				}

				view:nth-child(2) {
					font-size: 24rpx;
					font-weight: 400;
					color: #A0A0A0;
				}
			}
		}

		.content_box_2 {
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-top: 1rpx solid #F6F6F6;
			margin-top: 20rpx;
			padding-top: 15rpx;

			.content_box_2_left {
				display: flex;
				align-items: center;

				view:nth-child(1) {
					font-size: 24rpx;
					font-weight: 400;
					color: #343434;
				}

				view:nth-child(2) {
					width: 33rpx;
					height: 33rpx;
					margin-left: 10rpx;
				}
			}

			.content_box_2_right {
				width: 151rpx;
				height: 58rpx;
				background: #6F3810;
				border-radius: 29rpx;

				font-size: 24rpx;
				font-weight: 400;
				color: #FFFFFF;
				line-height: 58rpx;
				text-align: center;
			}
		}

		.rule {
			width: 299rpx;
			background: #FFFFFF;
			box-shadow: 0rpx 2rpx 10rpx 0rpx rgba(0, 0, 0, 0.13);
			border-radius: 8rpx;
			position: relative;
			bottom: 5rpx;
			left: -20rpx;
			padding: 20rpx 20rpx;
			font-size: 24rpx;
			font-weight: 400;
			color: #A0A0A0;
		}
	}
</style>